// webpack.dev.js (开发环境配置)
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');

const glob = require('glob');
const path = require('path');
// const PurgeCSSPlugin = require('purgecss-webpack-plugin');
const { PurgeCSSPlugin } = require("purgecss-webpack-plugin");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');



module.exports = merge(common, {
    mode: 'development',
    devtool: 'inline-source-map', // 开发环境下使用 source map
    devServer: {
        static: path.resolve(__dirname, 'dist'),
        port: 8080,
        hot: true,
    },
    plugins: [
        new MiniCssExtractPlugin({
            filename: 'css/[name].css', // 不使用哈希值缓存
        }),
        
        // new PurgeCSSPlugin({
        //     paths: glob.sync(`${path.resolve(__dirname, 'src')}/**/*`, { nodir: true }),
        //     safelist: [],
        // }),
        
    ],

    optimization: {
        minimize: false, // 禁用代码压缩
    },
});